//
//  SignUpDetailViewController.swift
//  FridgeSolo
//
//  Created by LiuXing on 2017/6/10.
//  Copyright © 2017年 kumi.com. All rights reserved.
//

import UIKit

class SignUpStep2ViewController: UIViewController {
    
    
    @IBOutlet weak var tallTextField: UITextField!
    @IBOutlet weak var weightTextField: UITextField!
    @IBOutlet weak var goalWeightTextField: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        title = "YOU"
        navigationItem.rightBarButtonItem =  nextButtonItem
    }
    
    private lazy var nextButtonItem: UIBarButtonItem = {
        let nextButtonItem = UIBarButtonItem(image: UIImage(named:"next"), style: .plain, target: self, action: #selector(nextButtonItemClick))
        nextButtonItem.tintColor = UIColor.white
        return nextButtonItem
    }()
    
    @objc private func nextButtonItemClick() {
        if tallTextField.text == nil {
            HudTool.shareInstance.showEorrorMessage(errorMessage: "please enter how tall are you")
            return
        }
        
        if weightTextField.text == nil {
            HudTool.shareInstance.showEorrorMessage(errorMessage: "please enter how much do you weight")
            return
        }
        
        if goalWeightTextField.text == nil {
            HudTool.shareInstance.showEorrorMessage(errorMessage: "What's your goal of weigh?")
            return
        }
        
        // 保存下数据 身高
        UserAccountTool.shareIntance.account?.tall = tallTextField.text // 身高
        UserAccountTool.shareIntance.account?.weight = weightTextField.text // 体重
        UserAccountTool.shareIntance.account?.goalWeight = goalWeightTextField.text // 目标体重
        
        let sb = UIStoryboard(name: "LogInAndSignUp", bundle: nil)
        let vc = sb.instantiateViewController(withIdentifier: "SignUpStep3ViewController") as! SignUpStep3ViewController
        navigationController!.pushViewController(vc, animated: true)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
